package com.liuwei.spring.cloud.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuwei.spring.cloud.biz.repository.db.entity.Users;
import com.liuwei.spring.cloud.biz.repository.db.mapper.UsersMapper;
import com.liuwei.spring.cloud.biz.service.MockService;
import com.liuwei.spring.cloud.biz.service.UsersService;
import com.liuwei.spring.cloud.framework.constants.RedisCache;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author : UsersServiceImpl
 * @version V1.0
 * @date: 2023/12/27 10:07 PM
 * @Description: TODO
 */
@Slf4j
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements UsersService {

    @Resource
    MockService iMockService;

    @Override
    @Cacheable(key="'springcloud:'+#name",cacheNames = {RedisCache.REDIS_TTL_30_SECONDS},cacheManager=RedisCache.CACHE_MANAGER)
    public Users getUserByUid(Integer uid, String name){
        log.info("Users|getByUserId:{}",uid);
        LambdaQueryWrapper<Users> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Users::getId,uid);
        return getOne(wrapper);
    }
}
